package com.fit.pages;

import org.apache.tapestry5.annotations.InjectPage;
import org.apache.tapestry5.annotations.OnEvent;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.annotations.SessionState;
import org.apache.tapestry5.ioc.annotations.Inject;


import com.fit.interfaces.Borrow;
import com.fit.interfaces.Car;
import com.fit.interfaces.User;
import com.fit.service.Borrows;

public class ViewBorrow {

	@SessionState
	private User user;
	
	private boolean userExists;
	
	Object onActivate(){
		if(!userExists) return Login.class;
		return null;
	}
	//promjena zadnja
	public User getUser(){
		return user;
	}
	
	@Inject
	@Property
	private Borrows borrows;
	
	@Property
	private Borrow currentBorrow;
	
	public Car getFirstCar(){
		return currentBorrow.getCar().get(0);
	}
	
//	@Inject
//	private Damage damage;
	
	@InjectPage
	private RecordsOfDamagedCars record;
	
	@OnEvent
	Object onActionFromDamage(String id){
		//String id = currentBorrow.getID();
		//System.out.println("ovo je id koji prosledjujem:"+id);
		 record.setPassedId(id);
		
		return record;
	}
}
